<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:c="http://java.sun.com/jstl/core"
      xmlns:s="http://jboss.com/products/seam/taglib"
      xmlns:a="http://richfaces.org/a4j"
      xmlns:r="http://richfaces.org/rich"
      xmlns:m="http://www.caradvert.com/main">

<ui:composition template="/content/templates/adminTemplate.xhtml">
    <ui:param name="selectedMenuSub1" value="adverts"/>
    <ui:define name="title">#{labels['ADVERTS']}</ui:define>
    <ui:define name="headContent">
        <script type="text/javascript" src="/resources/lightbox/lightbox.js"></script>
        <link rel="stylesheet" href="/resources/lightbox/lightbox.css" type="text/css"/>
    </ui:define>
    <ui:decorate template="/content/templates/contentDecorator.xhtml">

        <ui:include src="/content/components/sellAdvertDetailsComponent.xhtml">
            <ui:param name="advert" value="#{viewAdvertDetailsBean.advert}"/>
            <ui:param name="backUrl" value="#{ctxPath}/content/pages/admin/adverts.xhtml"/>
        </ui:include>
        
        <h:form>
            <table style="margin:0 auto 0 auto;">
                <tr>
                    <td>
                        <h:commandButton value="#{labels['APPROVE']}"
                                         action="#{adminBean.approveAdvert(viewAdvertDetailsBean.advert)}"/>
                        <input type="button" value="#{labels['REJECT']}" onclick="#{r:component('modalPanel')}.show()"/>
                    </td>
                </tr>
            </table>
        </h:form>

        <r:modalPanel  id="modalPanel" height="160" width="380">
            <f:facet name="header">
                #{labels['REJECT_REASON']}
            </f:facet>

            <h:form>
                <table style="margin:auto auto auto auto;">
                    <tr>
                        <td>
                            <h:inputTextarea value="#{viewAdvertDetailsBean.advert.rejectReason}" styleClass="text"
                                    validatorMessage="#{labels['FIELD']} '#{labels['REJECT_REASON']}' #{labels.get('SYMBOLS_COUNT_EXCEED', 1000)}">
                                <f:validateLength maximum="1000"/>
                            </h:inputTextarea>
                        </td>
                    </tr>
                    <tr>
                        <td class="rj">
                            <h:commandButton value="#{labels['READY']}"
                                             action="#{adminBean.rejectAdvert(viewAdvertDetailsBean.advert)}"/>
                            <input type="button" value="#{labels['CANCEL']}" onclick="#{r:component('modalPanel')}.hide()"/>
                        </td>
                    </tr>
                </table>
            </h:form>

        </r:modalPanel>

    </ui:decorate>
</ui:composition>
</html>